package com.student.dao.impl;

import java.util.List;

import org.springframework.stereotype.Component;

import com.student.dao.TeacherInfoDao;
import com.student.model.Teacher;

@Component("teacherSearchDao")
public class TeacherInfoDaoImpl extends HibernateDaoImpl implements
		TeacherInfoDao {

	public Teacher getTeacherByNumber(String teacherNumber) throws Exception {
		String hql = "FROM Teacher t where t.teacherNumber = " + teacherNumber;
		List<Teacher> teacher = this.find(hql);
		return teacher.get(0);
	}

	public void updateTeacher(String mobile, String phone, String qq,
			String email, String teacherNumber) throws Exception {
		if (mobile != null && phone != null && qq != null && email != null) {
			Object[] parameters = new Object[] { mobile, phone, qq, email };
			String hql = "update Teacher t set t.mobile=? , t.phone=? ,t.qq=? ,t.email=? where t.teacherNumber=" + teacherNumber;
		this.updateByQuery(hql, parameters);
		}

	}

}
